﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using Microsoft.WowAddonStudio.FrameXml.Serialization.TypeConverters;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization 
{
    [Serializable]
    [DesignerCategory("code")]
    [XmlType(Namespace = "http://www.blizzard.com/wow/ui/")]
    [DebuggerDisplay("Top = {Top}, Left = {Left}, Bottom = {Bottom}, Right = {Right}")]
	[TypeConverter(typeof(InsetTypeConverter))]
    public class Inset : SerializationObject, ICloneable, ICopiable<Inset>
    {
		/// <summary>
		/// Initializes a new instance of the <see cref="Inset"/> class.
		/// </summary>
    	public Inset()
    	{
    	}

		/// <summary>
		/// Initializes a new instance of the <see cref="Inset"/> class.
		/// </summary>
		/// <param name="allValues">All values.</param>
		internal Inset(int allValues)
		{
			Left = allValues;
			Right = allValues;
			Top = allValues;
			Bottom = allValues;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Inset"/> class.
		/// </summary>
		/// <param name="left">The left.</param>
		/// <param name="right">The right.</param>
		/// <param name="top">The top.</param>
		/// <param name="bottom">The bottom.</param>
    	internal Inset(int left, int right, int top, int bottom)
    	{
    		Left = left;
    		Right = right;
    		Top = top;
    		Bottom = bottom;
    	}

    	/// <summary>
        /// Gets or sets the left value.
        /// </summary>
        [XmlAttribute("left")]
        [NotifyParentProperty(true)]
		[Description("The left value of Inset.")]
        public int Left { get; set; }

        /// <summary>
        /// Gets or sets the right value.
        /// </summary>
        [XmlAttribute("right")]
        [NotifyParentProperty(true)]
		[Description("The right value of Inset.")]
        public int Right { get; set; }

        /// <summary>
        /// Gets or sets the top value.
        /// </summary>
        [XmlAttribute("top")]
        [NotifyParentProperty(true)]
		[Description("The top value of Inset.")]
        public int Top { get; set; }

        /// <summary>
        /// Gets or sets the bottom value.
        /// </summary>
        [XmlAttribute("bottom")]
        [NotifyParentProperty(true)]
		[Description("The bottom value of Inset.")]
        public int Bottom { get; set; }

        /// <summary>
        /// Creates a new object that is a copy of the instance.
        /// </summary>
        /// <returns>The copied instance.</returns>
        /// <remarks>Performs a deep copy.</remarks>
        public Inset Copy()
        {
            return new Inset(this.Left, this.Right, this.Top, this.Bottom);
        }

        /// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
    	public override string ToString()
    	{
			return string.Format("Inset: [Top = {0}, Left = {1}, Bottom = {2}, Right = {3}]", Top, Left, Bottom, Right);
    	}

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            return this.Copy();
        }
    }
}